<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *员工列表
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'oneadd';
$tabs=array(
	array('op'=>'oneadd','title'=>'单个添加'),
	array('op'=>'listadd','title'=>'批量导入'),
);
if($_RQ['op']=='oneadd'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->model('member')->add($postdata);
		if($_SESSION['role_id']==6){
			exi('添加成功','','/role6.list//status=all');
		}else{
			exi('添加成功','','/role3.list//status=0');
		}
	}
	$return['item']=array();
	$htmls=array(
		'type'=>'edit',
		'tabs'=>$tabs,
		'edit'=>$this->model('member')->edit_item(),
	);
	$return['sex']=$this->sex;
	$return['xueli_type']=$this->xueli_type;
	$return['from_type']=$this->member_from_type;
	unset($htmls['edit'][3]);
	if($_SESSION['store_type']==3){
		$return['from_type'][2]='来源渠道';
		$return['item']['from_type']=2;
		unset($return['from_type'][1]);
	}else{
		$return['from_type'][1]='来源渠道';
		$return['item']['from_type']=1;
		unset($return['from_type'][2]);
	}
	$return['member_from1_type']=$this->member_from1_type;
	$return['member_from2_type']=$this->member_from2_type;
	$return['jj_guanxi']=$this->jj_guanxi;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='listadd'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(!$postdata['from_type']){
			exi('请选择【导入类型】','error');
		}
		$this->model('member')->daoru($postdata);
		if($_SESSION['role_id']==6){
			exi('导入成功','','/role6.list//status=all');
		}else{
			exi('导入成功','','/role3.list//status=0');
		}
	}
	$return['item']=array('merchid'=>$merchid);
	$return['item']['excelurl']=SITEROOT.'/addons/jy_yxw/resource/addmember.csv';
	//$return['item']['excelurl']='请直接下载模板选择导入！';
	$htmls=array (
		  'type' => 'edit',
		  'tabs'=>$tabs,
		  'edit' => array (
				array ('type' => 'tip','title' => '<red>[温馨提示]：在导入过程中，请不要进行任何操作!</red></br>
				功能介绍：可将本模块导出的CSV文件快速上传,节约您的大量时间!</br>
				1、对于与全集团公司已经“交过预成交/定金”、“已经报过名”的信息重复则不能再导入；</br>
				2、以“城市”为单位，同一个城市的门店的实体资源客户重复不可导入（无时间限制，永久不重复）；</br>
				4、<red>文件表格日期不能带日期格式公式，否则程序识别不了</red>！
				'),
				array ('name' => 'excelurl','type' => 'copy','title' => 'CSV示例文件下载'),
				array ('name' => 'from_type','type' => 'radio','title' => '导入类型','options'=>'from_type'),
				array ('name' => 'excel','type' => 'upfile','title' => '上传CSV','help'=>'<red>别的表复制内容到新表？如果两个表编码不一样，复制后，会导致新的表编码异常，会导致导入异常。解决办法：先把需被复制的表，统一改成UTF-8编码，然后再复制内容到新表，就行！</red>'),
		  ),
	);
	if($_SESSION['store_type']==3){
		$return['from_type']=array(2=>'来源渠道');
	}else{
		$return['from_type']=array(1=>'来源渠道');
	}
	$return['htmls']=$htmls;
	exi($return);
}